package com.yoo.ons.dialog

import android.app.Activity
import android.view.animation.AnimationUtils
import android.widget.TextView
import androidx.fragment.app.FragmentActivity
import com.gyf.immersionbar.ImmersionBar
import com.yoo.module_base.utils.setSystemBottomNavBarColor
import com.yoo.module_base.utils.setSystemBottomNavBarNoColor
import com.yoo.ons.R
import razerdp.basepopup.BasePopupWindow

class PictureSelectTypePopup(var activity: FragmentActivity,val listener:SelectListener) :  BasePopupWindow(activity) {

    init {
        setContentView(R.layout.popup_upload_photo)
        initView()
        showAnimation=  AnimationUtils.loadAnimation(activity, com.yoo.module_res.R.anim.anims_slide_in_bottom)
        dismissAnimation=  AnimationUtils.loadAnimation(activity, com.yoo.module_res.R.anim.anims_slide_out_bottom)
    }

    private fun initView() {
        val dialogCancel = findViewById<TextView>(R.id.dialog_cancel)
        dialogCancel.setOnClickListener {
            dismiss()
        }
        val dialogOpenAlbums = findViewById<TextView>(R.id.dialog_open_albums)
        val dialogOpenCamera = findViewById<TextView>(R.id.dialog_open_camera)
        dialogOpenCamera.setOnClickListener {
            listener.onSelectCameraListener()
            dismiss()
        }
        dialogOpenAlbums.setOnClickListener {
            listener.onSelectAlbumsListener()
            dismiss()
        }
        setOutSideDismiss(true)

        //设置底部导航栏颜色
        setSystemBottomNavBarColor(activity)
        onDismissListener =object : OnDismissListener() {
            override fun onDismiss() {
                setSystemBottomNavBarNoColor(activity)
            }

        }
    }

    interface SelectListener{
        fun onSelectAlbumsListener()
        fun onSelectCameraListener()
    }
}